package com.hyh.prize.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyh.prize.entity.TabGgcardInfo;
import com.hyh.prize.mapper.GgkMapper;
import com.hyh.prize.service.GgkService;
import com.hyh.prize.entity.TabGgcardInfo;
import org.springframework.stereotype.Service;

@Service
public class GgkServiceImpl extends ServiceImpl<GgkMapper, TabGgcardInfo> implements GgkService {
    @Override
    public Boolean seveGgk(TabGgcardInfo tabGgcardInfo) {
        boolean b;
        TabGgcardInfo ggk = this.getById(tabGgcardInfo.getCardno());
        if(ggk!=null){//如果不为空，执行更新
            ggk.setPrizelevel(tabGgcardInfo.getPrizelevel());
            ggk.setState(tabGgcardInfo.getState());
            ggk.setOptrid(tabGgcardInfo.getOptrid());
            b= this.updateById(ggk);
        }else{//执行添加操作
           b= this.save(tabGgcardInfo);
        }
        return b;
    }

    /**
     * 根据刮刮卡id查询奖品等级
     * @param ggkid
     * @return
     */
    public String exzhong(String ggkid){
        TabGgcardInfo ggcardInfo = this.getById(ggkid);
        return ggcardInfo.getPrizelevel()+"";
    }

    /**
     * 修改刮刮卡状态
     * @param ggkid
     * @return
     */
    public boolean update(String ggkid){
        TabGgcardInfo ggcardInfo = this.getById(ggkid);
        if(ggcardInfo!=null){
            //修改领取状态
            ggcardInfo.setState("7");
            this.updateById(ggcardInfo);
            return true;
        }
        return false;
    }

}
